package timberman.character;

import java.util.HashMap;
import java.util.Iterator;


import timberman.core.MyGame;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.Array;

public class ManLibrary {
	HashMap<String,Animation> listAnimation = new HashMap<String,Animation>();
	
	
	public ManLibrary(){
		loadMans();
	}
		
	/**
	 * get Animation by pass name of MANTYPE
	 * @param manType
	 * @return
	 */
	public Animation getMan(String manType){
		if(manType == null){
			System.out.println("String null");
		}
		if(listAnimation == null){
			System.out.println("List null");
		}
		if(listAnimation.get(manType.toString().toUpperCase()) != null){
			System.out.println("Animatedddddd");
		}
		return listAnimation.get(manType.toString().toUpperCase());
	}
	
	/**
	 * allow user add any animation for MAN with TypeName
	 * @param manType
	 * @param animation
	 */
	public void addMan(String manType, Animation animation){
		listAnimation.put(manType.toString().toUpperCase(), animation);
	}
	
	/**
	 * load all MANTYPE,ANIMATION from resource
	 */
	public void loadMans(){
		// perform load all animation with name from resource
		TextureAtlas ball_atlas = MyGame.getInstance().manager.get(GameInfo.MAN_NIMATION);
		//
		Animation anim_man = new Animation(0.05f,
				ball_atlas.findRegions("man"));
//		anim_man.setPlayMode(Animation.PlayMode.LOOP_REVERSED);
		listAnimation.put("BASICMAN", anim_man);
		
	}
	
	/**
	 * get All Man Type Name from resource
	 * @return
	 */
	public Array<String> getAllManTypeName(){
		Array<String> resultListManName = new Array<String>();
		Iterator<String> listName = listAnimation.keySet().iterator(); 
		while(listName.hasNext()){
			resultListManName.add(listName.next());
		}
		return resultListManName;
	}

}
